Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict tagged template language injections for ecma #12217

Conversation

uncenter
Copy link
Contributor

@uncenter uncenter commented Dec 8, 2024

Closes #11952.

@clo4
Copy link
Contributor

clo4 commented Dec 8, 2024

What problem is this solving for you? I find this feature quite useful, at least for highlighting SQL, and I've used this with graphql in the past. And, slightly cursed, but also for highlighting bash and python using JS as the glue code.

Edit: nevermind, somehow I glossed over the issue.

@uncenter
Copy link
Contributor Author

uncenter commented Dec 8, 2024

What problem is this solving for you? I find this feature quite useful, at least for highlighting SQL, and I've used this with graphql in the past. And, slightly cursed, but also for highlighting bash and python using JS as the glue code.

Edit: nevermind, somehow I glossed over the issue.

Happy to add those to the list! sql, python, and bash... any others?

@the-mikedavis the-mikedavis added the A-language-support Area: Support for programming/text languages label Dec 9, 2024
@aster-void
Copy link
Contributor

slightly off-context (as this PR currently only limits injection and not extend it), but is it possible to support Bun's $ shell API?
the syntax looks similar to bash.

https://bun.sh/docs/runtime/shell

@uncenter
Copy link
Contributor Author

uncenter commented Jan 6, 2025

Yeah that would look like:

; Parse the contents of $ template literals for shell commands

(call_expression
  function: [
    (identifier) @_template_function_name
    (member_expression
      property: (property_identifier) @_template_function_name)
  ]
  arguments: (template_string) @injection.content
 (#eq? @_template_function_name "$")
 (#set! injection.language "bash"))

And would also work for https://github.com/sindresorhus/execa and https://github.com/google/zx. I can make a PR after this one for that feature.

@the-mikedavis the-mikedavis merged commit f70923c into helix-editor:master Jan 23, 2025
6 checks passed
@uncenter uncenter deleted the restrict-ecma-template-tag-injections branch January 23, 2025 21:47
nik-rev pushed a commit to nik-rev/helix that referenced this pull request Jan 24, 2025
nikola2501 pushed a commit to nikola2501/helix that referenced this pull request Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent syntax highlighting for tagged templates in JavaScript
4 participants